﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Koonsoft.Tool.CheckEveryday.Order.BLL
{
    public class ExceptionOrder
    {

        /// <summary>
        /// 获得异常订单信息
        /// </summary>
        /// <returns></returns>
        public ExceptionOrderInfo GetExceptionOrder()
        {
            Koonsoft.Tool.CheckEveryday.Order.DAL.ExceptionOrder dal = new Koonsoft.Tool.CheckEveryday.Order.DAL.ExceptionOrder();

            return dal.GetExceptionOrder();
        }

        /// <summary>
        /// 生成发送短信的报告
        /// </summary>
        /// <returns></returns>
        public string GetReport()
        {
            ExceptionOrderInfo orderinfo = GetExceptionOrder();

            StringBuilder report = new StringBuilder();

            if (orderinfo.CommitingOrders > 0)
            {
                report.Append(string.Format("提交中{0}，", orderinfo.CommitingOrders));
            }
            if (orderinfo.WaitingConfirmButConfirmedOrders > 0)
            {
                report.Append(string.Format("等待确认但已确认{0}，", orderinfo.WaitingConfirmButConfirmedOrders));
            }
            if (orderinfo.DispatchingButWithoutRequestOrders > 0)
            {
                report.Append(string.Format("配送中无配送请求{0}，", orderinfo.DispatchingButWithoutRequestOrders));
            }
            if (orderinfo.DispatchingButDispatchedOrders > 0)
            {
                report.Append(string.Format("等待配送但已完成配送{0}，", orderinfo.DispatchingButDispatchedOrders));
            }
            if (orderinfo.FinishedButStillOnDeliveringOrders > 0)
            {
                report.Append(string.Format("业务受理中但已受理完{0}，",orderinfo.FinishedButStillOnDeliveringOrders));
            }
            if (orderinfo.PaidButWaitingPayOrders > 0)
            {
                report.Append(string.Format("等待支付但已支付{0}，", orderinfo.PaidButWaitingPayOrders));
            }
            if (orderinfo.CollectOnDeliveryButWaitingPayOrders > 0)
            {
                report.Append(string.Format("货到付款但等待支付{0}，",orderinfo.CollectOnDeliveryButWaitingPayOrders));
            }
            if (orderinfo.OvertimeImportTempOrders > 0)
            {
                report.Append(string.Format("超过12小时仍在导入中{0}，",orderinfo.OvertimeImportTempOrders));
            }

            return report.ToString();
        }
    }
}
